public class demo1 {
    int []temp;
    public int[] sortArray(int[] nums){
        gbin(nums,0,nums.length-1);
        temp=new int[nums.length];
        return nums;
    }
    public void gbin(int[] nums,int l,int r){
        if(l>=r)return;
        int mid=(l+r)/2;
        gbin(nums,l,mid);
        gbin(nums,mid+1,r);
        int left=l,right=mid+1,x=0;
        while(left<=mid&&right<=r){
            temp[x++]=nums[left]<=nums[right] ? nums[right++]:nums[left++];
        }
        while(left<=mid)temp[x++]=nums[left++];
        while(right<=r)temp[x++]=nums[right++];
        for(int i=l;i<=r;i++){
            nums[i]=temp[i-l];
        }
    }
}
